package com.zg.datapush.exception;

/**
 * 数据推送异常类
 * @author zg
 */
public class DataPushException extends RuntimeException {

    private String errorCode;

    public DataPushException(String message) {
        super(message);
    }

    public DataPushException(String message, Throwable cause) {
        super(message, cause);
    }

    public DataPushException(String errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public DataPushException(String errorCode, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = errorCode;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    // 常用错误码
    public static class ErrorCodes {
        public static final String DATASOURCE_NOT_FOUND = "DATASOURCE_NOT_FOUND";
        public static final String TABLE_NOT_FOUND = "TABLE_NOT_FOUND";
        public static final String FIELD_MAPPING_ERROR = "FIELD_MAPPING_ERROR";
        public static final String DATA_TRANSFORM_ERROR = "DATA_TRANSFORM_ERROR";
        public static final String CONNECTION_ERROR = "CONNECTION_ERROR";
        public static final String SQL_EXECUTION_ERROR = "SQL_EXECUTION_ERROR";
        public static final String HTTP_REQUEST_ERROR = "HTTP_REQUEST_ERROR";
        public static final String CUSTOM_HANDLER_ERROR = "CUSTOM_HANDLER_ERROR";
        public static final String SCHEDULE_ERROR = "SCHEDULE_ERROR";
        public static final String VALIDATION_ERROR = "VALIDATION_ERROR";
    }
}
